package net.spring_mybatis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @Author lj
 * @Date 2024/10/14 23:04
 * @Version 1.0
 */
@Configuration
@ComponentScan("net.spring_mybatis")
@Import({DataSourceConfig.class,MybatisConfig.class})
@EnableTransactionManagement
public class SpringConfig {

    @Bean
    public TransactionManager transactionManager(DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }
}
